" All system-wide defaults are set in $VIMRUNTIME/debian.vim (usually just
" /usr/share/vim/vimcurrent/debian.vim) and sourced by the call to :runtime
" you can find below.  If you wish to change any of those settings, you should
" do it in this file (/etc/vim/vimrc), since debian.vim will be overwritten
" everytime an upgrade of the vim packages is performed.  It is recommended to
" make changes after sourcing debian.vim since it alters the value of the
" 'compatible' option.

" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
runtime! debian.vim

" Uncomment the next line to make Vim more Vi-compatible
" NOTE: debian.vim sets 'nocompatible'.  Setting 'compatible' changes numerous
" options, so any other options should be set AFTER setting 'compatible'.
"set compatible

" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
if has("syntax")
  syntax on
endif

" Set for python
" Execute current python script file in vim
"map <F3> :!python %<cr>
" Save file and execute current python script file in vim
"map <F4> :w\|!python %<cr>
" Execute file being edited with <Shift> + e:
map <buffer> <S-e> :w<CR>:!python % <CR>
" End set for python

" If using a dark background within the editing area and syntax highlighting
" turn on this option as well
"set background=dark

" Uncomment the following to have Vim jump to the last position when
" reopening a file
"if has("autocmd")
"  au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
"endif

" Uncomment the following to have Vim load indentation rules and plugins
" according to the detected filetype.
if has("autocmd")
  filetype plugin indent on
endif

" The following are commented out as they cause vim to behave a lot
" differently from regular Vi. They are highly recommended though.

" Set for phpmyadmin
"set expandtab
"set shiftwidth=4
"set softtabstop=4
"set tabstop=4
" End of set for phpmyadmin

" Set for postgresql
"set tabstop=4
"set shiftwidth=4
"set noexpandtab
" End of set for postgresql

" Set for pulseaudio
set tabstop=4
set shiftwidth=4
set expandtab
" End of set for pulseaudio


set encoding=utf-8
"set fileencodings=utf-8,gbk,chinese
"if has("win32")
"    set fileencoding=chinese
"else
"    set fileencoding=utf-8
"endif
"set termencoding=utf-8
"set encoding=prc
"language messages zh_CN.utf-8
set scrolloff=3
set showmode
set hidden
set wildmenu
set wildmode=list:longest
set visualbell
set cursorline
set ttyfast
set ruler
set backspace=indent,eol,start
set laststatus=2
"set relativenumber
set number
set undofile
set list

set autoindent
"set cindent

let mapleader = ","

"nnoremap / /\v
"vnoremap / /\v
"set number
set foldcolumn=4
set foldmethod=syntax
set showcmd		" Show (partial) command in status line.
set ignorecase		" Do case insensitive matching
set smartcase		" Do smart case matching
"set gdefault
set incsearch		" Incremental search
set showmatch		" Show matching brackets.
set hlsearch
nnoremap <leader><space> :noh<cr>
"nnoremap <tab> %
"vnoremap <tab> %
"set autowrite		" Automatically save before commands like :next and :make
"set hidden             " Hide buffers when they are abandoned
"set mouse=a		" Enable mouse usage (all modes)

set wrap
set textwidth=79
set formatoptions=qrn1
set colorcolumn=85

" Disable the arrow keys while in normal mode
nnoremap <up> <nop>
nnoremap <down> <nop>
nnoremap <left> <nop>
nnoremap <right> <nop>
" Disable the arrow keys while in insert mode
inoremap <up> <nop>
inoremap <down> <nop>
inoremap <left> <nop>
inoremap <right> <nop>
"nnoremap j gj
"nnoremap k gk

inoremap <F1> <ESC>
nnoremap <F1> <ESC>
vnoremap <F1> <ESC>

"nnoremap ; :

"au FocusLost * :wa

" Strip all trailing whitespace in the current file
"nnoremap <leader>W :%s/\s\+$//<cr>:let @/=''<CR>
" Quickly open up ~/.vimrc file in a vertically split window
"nnoremap <leader>ev <C-w><C-v><C-l>:e $MYVIMRC<cr>
" Open a new vertical split window and switch over to it
"nnoremap <leader>w <C-w>v<C-w>l
" Move around splits window
"nnoremap <C-h> <C-w>h
"nnoremap <C-j> <C-w>j
"nnoremap <C-k> <C-w>k
"nnoremap <C-l> <C-w>l

" Taglist variables
" Display function name in status bar
let g:ctags_statusline=1
" Automatically start script
let generate_tags=1
" Displays taglist results in vertical window
let Tlist_Use_Horiz_Window=0
" Shorter commands to toggle Taglist display
nnoremap TT :TlistToggle<CR>
map <F4> :TlistToggle<CR>
" various Taglist display config
let Tlist_Use_Left_Window = 1
"let Tlist_Use_Right_Window = 1
let Tlist_Compact_Format = 1
let Tlist_Exit_OnlyWindow = 1
let Tlist_GainFocus_On_ToggleOpen = 1
let Tlist_File_Fold_Auto_Close = 1
"let Tlist_Show_One_File=1
"let Tlist_Exit_OnlyWindow=1

let g:winManagerWindowLayout='FileExplorer|TagList'

nnoremap wm :WMToggle<cr>
nnoremap <c-w><c-t> :WMToggle<cr>

set cscopequickfix=s-,c-,d-,i-,t-,e-
let g:miniBufExplMapCTabSwitchBufs=1
let g:miniBufExplMapWindowNavVim=1

nnoremap <silent><F12> :A<CR>

"let g:SuperTabRetainCompletionType=2
let g:SuperTabDefaultCompletionType="context"
"let g:SuperTabDefaultCompletionType="<C-X><C-O>"

"colorscheme elflord

" Source a global configuration file if available
if filereadable("/etc/vim/vimrc.local")
  source /etc/vim/vimrc.local
endif

if match(getcwd(), "/pgsql") >= 0 || match(getcwd(), "/postgresql") >= 0
  set cinoptions=(0
  set tabstop=4
  set shiftwidth=4
endif

" Ctags
set tags=tags;
set autochdir

" Dictionary word completion using Ctrl-x Ctrl-k
set dictionary+=/usr/share/dict/words

" Pydiction plugin
" Set completion dictionary file
let g:pydiction_location = "/usr/local/share/vim/vim73/complete-dict"
" Set the height of the completion menu
let g:pydiction_menu_height = 15
" You should *** NOT *** have this in your vimrc anymore:
"if has("autocmd")
"    autocmd FileType python set complete+=k/path/to/pydiction iskeyword+=.,(
"endif ' has("autocmd")

" SnippetsEmu
" Remap the trigger key
let g:snippetsEmu_key = "<F2>"

" Vim-markdown
let g:vim_markdown_folding_disabled=1
let g:vim_markdown_initial_foldlevel=1
